
#include "SpriteArea.h"
using namespace std;



SpriteArea::SpriteArea()
{
}

SpriteArea::~SpriteArea()
{
}


void SpriteArea::setImage(Glib::RefPtr<Gdk::Pixbuf> &image, int src_x, int src_y, int width, int height)
{
    m_image = image;
    r.m_x = src_x;
    r.m_y = src_y;
    r.m_w = width;
    r.m_h = height;
    repaint();
}

bool SpriteArea::repaint(void)
{
    if (m_image) {
        m_image->render_to_drawable(get_window(), get_style()->get_black_gc(),
            r.m_x, r.m_y, 0, 0, r.m_w, r.m_h, Gdk::RGB_DITHER_NONE, 0, 0);
    }
    return false;
}


bool SpriteArea::on_expose_event(GdkEventExpose* ev)
{
    if (Debug::test(DEBUG_EVENT)) {
        cout << "SpriteArea::on_expose_event" << endl;
    }
    repaint();
    return 0;
}
